from configparser import ConfigParser
import os

class ReadConfig(object):
    def __init__(self):
        self.config = ConfigParser()
        self.conf_path = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), 'config',
                                      'config.ini')  # 读取绝对路径
        self.config.read(self.conf_path, encoding='utf-8')

    def get(self,section,option):
        value = self.config.get(section, option)
        return value


if __name__ == '__main__':
    conf = ReadConfig()
    a = conf.get('mail','mail_host')
    print(a)